package com.yixing.tech.wms.controller;

import com.yixing.tech.common.base.BaseControl;
import com.yixing.tech.common.base.BusinessException;
import com.yixing.tech.common.base.Rs;
import com.yixing.tech.wms.param.InStockTaskParam;
import com.yixing.tech.wms.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 库存
 *
 * @author yixing tech
 * @since 1.0.0
 */
@RestController
@CrossOrigin
@RequestMapping(value = "/stock")
public class StockController extends BaseControl {

    @Autowired
    private StockService stockService;

    /**
     * 更具上架作业更新库存
     */
    @PostMapping("/update/byUpTask")
    public Rs<Object> updateInStock(@RequestBody InStockTaskParam param) throws BusinessException {
        return Rs.ok(stockService.updateInStock(param.getTaskCode()));
    }

    /**
     * 统计哪些货位是有货物，哪些货物是有空箱子
     */
    @GetMapping("/stats/location/container")
    public Rs<Object> statsLocationContainer() throws BusinessException {
        return Rs.ok(stockService.statsLocationContainer());
    }

}
